package com.youlu.campus.web.activity;

import com.youlu.campus.activity.entity.ActivityLotteryConfigPrizeVo;
import com.youlu.campus.activity.entity.UserLotteryInfoVo;
import com.youlu.campus.activity.service.UserLotteryInfoService;
import com.youlu.campus.entity.UserPO;
import com.youlu.campus.web.common.base.RequestContext;
import com.yuelin.infrastructure.quantum.common.QResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户抽奖详情
 *
 * @Description: UserLotteryInfoController
 * @Date 2025/7/31
 * @module UserLotteryInfoController
 * @author: su
 */
@Slf4j
@RestController
@RequestMapping("/api/user-lottery")
public class UserLotteryInfoController {

    @Autowired
    private UserLotteryInfoService userLotteryInfoService;

    /**
     * 通过活动id 获取用户抽奖详情
     *
     * @param activityId
     * @return
     */
    @GetMapping("/info")
    public QResult<UserLotteryInfoVo> getUserLotteryInfo(@RequestParam String activityId) {
        UserPO curUser = RequestContext.getCurUser();
        return QResult.success(userLotteryInfoService.getUserLotteryInfo(activityId,curUser));
    }

    /**
     * 用户抽奖
     *
     * @param activityId
     * @return
     */
    @PostMapping("/draw")
    public QResult<ActivityLotteryConfigPrizeVo> draw(@RequestParam String activityId) {
        UserPO curUser = RequestContext.getCurUser();
        ActivityLotteryConfigPrizeVo info = userLotteryInfoService.draw(activityId, curUser);
        return QResult.success(info);
    }
}
